package ExceptionTest;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Test07 {
    public static void main(String[] args) {
        //文件读取器
        FileReader reader = null;
        try {
            //读取D盘文件下 a的内容
            reader = new FileReader("d://a.txt");
            //读取字符
            char c= (char) reader.read();
            char c2= (char) reader.read();
            System.out.println(""+c+c2);
            //文件异常不存在--FileNotFoundException
        }catch (FileNotFoundException e){
            e.printStackTrace();
            //文件读不尽--IOException
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            try {
                //关闭资源
                if (reader != null){
                    reader.close();
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
